import Vue from 'vue'
import Router from 'vue-router'

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      name: 'Root',
      component: r => require(['@/components/Root.vue'], r)
    },
    {
      path: '/login',
      name: 'Login',
      meta: {allowAnonymous: true},
      component: r => require(['@/components/Login/Login.vue'], r)
    },
    {
      path: '/forgot-pwd',
      name: 'ForgotPwd',
      meta: {allowAnonymous: true},
      component: r => require(['@/components/Login/ForgotPwd.vue'], r)
    },
    {
      path: '/change-pwd',
      name: 'ChangePwd',
      extra: '修改密码',
      component: r => require(['@/components/Login/ChangePwd.vue'], r)
    },
    {
      path: '/plan-search',
      name: 'PlanSearch',
      extra: '作业计划申请查询',
      component: r => require(['@/components/Plan/PlanSearch/PlanSearch.vue'], r)
    },
  ]
})
